package cn.pegasus.teamwork.manager.controller;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import cn.iyizhan.teamwork.base.util.ParameterEunm;
import cn.iyizhan.teamwork.base.util.ReMessage;
import cn.pegasus.teamwork.sysconfig.entity.SysConfigFiles;
import cn.pegasus.teamwork.sysconfig.mapper.SysConfigFilesMapper;
import cn.pegasus.teamwork.sysconfig.service.SysConfigFilesService;

/**
 * @ClassName: SysConfigFilesController
 * @Description: 文件信息表
 * @author buyuer
 * @date 2015年11月26日 下午3:56:19
 * 
 */
@RequestMapping("/sysFiles/*")
@Controller
public class SysConfigFilesController extends BaseManagerController<SysConfigFiles, SysConfigFilesMapper> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysConfigFilesController.class);

    @Autowired
    private SysConfigFilesService filesService;

    @RequestMapping("/listFiles")
    public ModelAndView listFiles(@RequestParam Map<String, Object> map) {
        ModelAndView view = new ModelAndView("files/list-file");

        return view;
    }

    @RequestMapping("/saveFile")
    public Map<String, Object> saveFile(@RequestParam Map<String, Object> map) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        try {
            filesService.add(map);
            resultMap = ReMessage.resultBack(ParameterEunm.SUCCESSFUL_CODE, null);
        } catch (Exception e) {
            LOGGER.error("保存文件失败！", e);
            resultMap = ReMessage.resultBack(ParameterEunm.ERROR_500_CODE, null);
        }
        return resultMap;
    }

   
    
}
